library ItemAntiVenom initializer init requires LegacySystem

	private function AntiVenomConditions takes nothing returns boolean
		local integer i = GetSpellAbilityId()
		return i=='A03V'
	endfunction

	private function AntiVenom takes nothing returns nothing
		local unit u = GetTriggerUnit()
		local integer i = 1
		loop
			exitwhen i > 2
			call UnitRemoveAbility(u,'Bpoi')
			call UnitRemoveAbility(u,'A08B') //Infection Ability
			call UnitRemoveAbility(u,'BEah') //Infection Buff
			call UnitRemoveAbility(u,'Bpsd')
			call UnitRemoveAbility(u,'B008')
			set i = i + 1
		endloop
		if GetRandomInt(1,3)==1 then
			call UnitRemoveAbility(u,'B00B')
			call UnitRemoveAbility(u,'BNpa')
			call UnitRemoveAbility(u,'BNpm')
		endif
		set u = null
	endfunction

	private function init takes nothing returns nothing
		local trigger t
		set t = CreateTrigger()
		call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
		call TriggerAddCondition( t, Condition(function AntiVenomConditions) )
		call TriggerAddAction(t,function AntiVenom)
	endfunction

endlibrary